package com.ego.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ego.pojo.Stock;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * @author Ares
 */
public interface StockMapper extends BaseMapper<Stock> {

    @Update("update tb_stock set stock = stock-#{stock} where sku_id=#{skuId} and stock > #{stock}")
    int descrementStock(Long skuId, Integer stock);

    @Update("update  tb_stock  set seckill_stock = seckill_stock-1 where sku_id=#{skuId} and seckill_stock >= 1 ")
    int descrementSeckillStock(@Param("skuId")Long skuId);

}
